<template>
  <div class="blog-body">
    <!-- 轮播图 -->
    <div class="carousel-container">
      <el-carousel :interval="4000" type="card" height="320px">
        <el-carousel-item v-for="item in features" :key="item.id">
          <el-link :underline="false" :href="item.href" target="_blank" class="carousel-link">
            <div class="image-container">
              <el-image :src="item.img" class="carousel-image"></el-image>
              <h3 class="image-caption">{{ item.title }}</h3>
            </div>
          </el-link>
        </el-carousel-item>
      </el-carousel>
    </div>
    <!-- 文章列表 -->
    <div class="articles-list">
      <div class="articles-item" v-for="item in articles" :key="item.title">
        <el-link :underline="false" :href="item.path" class="article-link">
          <div class="article-image">
            <el-image :src="defaultImg"></el-image>
          </div>
        </el-link>
        <div class="article-info">
          <h3 class="article-title">{{ item.title }}</h3>
          <div class="article-meta">
            <span class="author">作者: {{ item.author }}</span>
            <span class="create-time">创建时间：{{ item.createTime }}</span>
          </div>
          <p class="article-desc">内容简介：{{ item.description }}</p>
        </div>
      </div>
    </div>
    <el-backtop class=".page-component__scroll .el-scrollbar__wrap" :bottom="100">
      <div class="back-to-top">返回顶部</div>
    </el-backtop>
  </div>
</template>

<script>
import defaultImg from "@/assets/defaultImg.jpg"
import akina from "@/assets/akina.jpg"
import theme from "@/assets/theme.jpg"
import myWorks from "@/assets/my-works.jpg"
export default {
  name: 'blogIndex',
  props: {
    msg: String
  },
  data() {
    return {
      defaultImg: defaultImg,
      articles: [
        {
          title: "文章标题1",
          author: "鱿鱼须",
          description: "简短介绍文章内容",
          createTime: "2018-06-01",
          path: "/articles/detail"
        },
        {
          title: "文章标题2",
          author: "鱿鱼须",
          description: "简短介绍文章内容",
          createTime: "2018-06-01",
          path: "/articles/detail"
        },
        {
          title: "文章标题3",
          author: "鱿鱼须",
          description: "简短介绍文章内容",
          createTime: "2018-06-01",
          path: "/articles/detail"
        },
        {
          title: "文章标题4",
          author: "鱿鱼须",
          description: "简短介绍文章内容",
          createTime: "2018-06-01",
          path: "/articles/detail"
        },
        {
          title: "文章标题5",
          author: "鱿鱼须",
          description: "简短介绍文章内容",
          createTime: "2018-06-01",
          path: "/articles/detail"
        },
        // 其他文章数据...
      ],
      features: [
        {
          id: 1,
          title: 'Akina',
          img: akina,
          href: 'https://zhebk.cn'
        },
        {
          id: 2,
          title: '源码地址',
          img: theme,
          href: 'https://gitee.com/fengziy/Fblog'
        },
        {
          id: 3,
          title: '博客开源地址',
          img: myWorks,
          href: 'https://gitee.com/liuzhexian/blog-demo'
        }
      ]
    }
  }
}
</script>

<style scoped>
.blog-body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.carousel-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.articles-list {
  width: 100%;
  align-content: center;
  max-width: 900px;
  margin-top: 20px;
}

.articles-item {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 20px;
}

.article-image {
  flex: 0 0 150px;
  margin-right: 20px;
}

.article-content h1 {
  margin: 0;
  font-size: 1.5em;
}

.article-content p {
  margin: 5px 0;
  color: #666;
}

.article-content p:last-child {
  margin-bottom: 0;
}

.carousel-image {
  width: 40%;
  height: 100%; /* 可以根据实际需求调整 */
  object-fit: cover;
}
.back-to-top {
  height: 100%;
  width: 100%;
  background-color: #f2f5f6;
  box-shadow: 0 0 6px rgba(0,0,0, .12);
  text-align: center;
  line-height: 30px;
  color: #1989fa;
}
::v-deep .el-backtop {
  width: 80px;
  height: 30px;
}
</style>

<style scoped>
/* 新增样式 */
.articles-item {
  display: flex;
  align-items: flex-start;
  margin: 20px 0;
  padding: 20px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s ease;
}

.articles-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.article-link {
  flex: 0 0 240px;
  margin-right: 25px;
}

.article-image {
  width: 100%;
  height: 160px;
  border-radius: 4px;
  overflow: hidden;
}

.article-image .el-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.article-image:hover .el-image {
  transform: scale(1.05);
}

.article-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.article-title {
  font-size: 22px;
  color: #2c3e50;
  margin: 0 0 12px;
  font-weight: 600;
  text-align: left; /* 新增左对齐 */
}

.article-meta {
  display: flex;
  gap: 20px;
  margin-bottom: 15px;
  color: #7f8c8d;
  font-size: 16px; /* 从14px调整为16px */
}

.article-desc {
  display: flex;
  font-size: 16px;
  line-height: 1.6;
  color: #666;
  margin: 0;
}

/* 响应式布局 */
@media (max-width: 768px) {
  .articles-item {
    flex-direction: column;
    padding: 15px;
  }

  .article-link {
    flex: none;
    width: 100%;
    margin-right: 0;
    margin-bottom: 15px;
  }

  .article-image {
    height: 200px;
  }
  
  .article-title {
    font-size: 18px;
  }
}
</style>

<style scoped>
/* 新增轮播图样式 */
.carousel-link {
  display: block;
  height: 100%;
  position: relative;
}

.image-container {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 8px;
}

.image-caption {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  padding: 15px;
  margin: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  color: rgba(255,255,255,0.9);
  text-align: center;
  font-size: 22px;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  letter-spacing: 1px;
}

.carousel-image {
  width: 100%;
  height: 100%;
  transition: transform 0.3s ease;
}

.image-container:hover .carousel-image {
  transform: scale(1.05);
}
</style>
